package cn.shadow.module.chess.message;

import cn.shadow.moulde.Modules;
import cn.shadow.utils.BufferUtil;
import io.netty.buffer.ByteBuf;
import static cn.shadow.utils.BufferUtil.newDynamicMessage;
import static cn.shadow.utils.BufferUtil.onlySendHeaderMessage;
/**
* 两人对战棋类通用
* Created by CodeMaker
* Created time: 2020-08-19 10:53:27
*/
public class ChessModuleMessages {
    public static final int MODULE_ID = Modules.CHESS_MODULE_ID;


    /**
    *点击一个坐标
    */
    public static final int C2S_CHESS_CLICK=3001;
    public static ByteBuf ClickMsg(int posX,int posY) {
        ByteBuf buffer = newDynamicMessage(MODULE_ID, C2S_CHESS_CLICK);

        BufferUtil.writeVarInt32(buffer,posX); //棋子x坐标
        BufferUtil.writeVarInt32(buffer,posY); //棋子Y坐标

        return buffer;
    }

    /**
    *邀请玩家进行游戏
    */
    public static final int C2S_CHESS_INVITE_PLAYER=3003;
    public static ByteBuf InvitePlayerMsg(long inviterId,long inviteeId,int chessType) {
        ByteBuf buffer = newDynamicMessage(MODULE_ID, C2S_CHESS_INVITE_PLAYER);

        BufferUtil.writeVarInt64(buffer,inviterId); //邀请玩家id
        BufferUtil.writeVarInt64(buffer,inviteeId); //被邀玩家id
        BufferUtil.writeVarInt32(buffer,chessType); //游戏类型

        return buffer;
    }

    /**
    *邀请玩家进行游戏
    */
    public static final int S2C_CHESS_INVITE_PLAYER=3004;

    /**
     *接受邀请
     */
    public static final int C2S_CHESS_ACCEPT=3005;
    public static ByteBuf AcceptMsg(int chessType,String gameId,long inviteeId) {
        ByteBuf buffer = newDynamicMessage(MODULE_ID, C2S_CHESS_ACCEPT);

        BufferUtil.writeVarInt32(buffer,chessType); //游戏类型
        BufferUtil.writeUTF(buffer,gameId); //游戏id
        BufferUtil.writeVarInt64(buffer,inviteeId); //被邀请者Id

        return buffer;
    }

    /**
    *邀请结果
    */
    public static final int S2C_CHESS_ACCEPT=3006;

    /**
    *发送开始开始对局请求
    */
    public static final int C2S_CHESS_START=3007;
    public static ByteBuf StartMsg(int chessType,String gameId) {
        ByteBuf buffer = newDynamicMessage(MODULE_ID, C2S_CHESS_START);

        BufferUtil.writeVarInt32(buffer,chessType); //游戏类型
        BufferUtil.writeUTF(buffer,gameId); //游戏id

        return buffer;
    }

    /**
    *开始对局响应,初始化棋盘
    */
    public static final int S2C_CHESS_START=3008;

}
